package cn.bdqn.text;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class HelloServlet2 extends HttpServlet {
    /**
     * 初始化方法
     */
    public void init() throws ServletException {
        System.out.println("初始化时，init() 方法被调用！");
    }
    /**
     * doGet()方法
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
        System.out.println("处理请求时，doGet()方法被调用。");
        System.out.println("处理请求时，doGet()方法被调用。");
        String initParam = getInitParameter("initParam2");     // 获取初始化参数
        String contextParam = this.getServletContext().getInitParameter("contextParam");
        System.out.println("Servlet 初始化参数" + initParam);
        System.out.println("上下文参数" + contextParam);
    }

}
